1. Field of the Invention
The present invention relates to the computer field, more particularly, to a virtual machine system and a method for sharing a graphics card amongst virtual machines.
2. Description of the Prior Art
The virtualization technologies have wide applications in the computer field with the development of computer systems. Modern computers are capable of supporting a plurality of virtual machines by means of the virtualization technologies and running a separate Guest Operating System (GOS) respectively on each virtual machine.
In a virtual machine system, all the individual operating systems need to access the hardware. Among others, the access to a graphics card is relative complex. How to use the graphics card is an important factor which influences users' experiences. At present, primary virtualization technologies, such as VMWare, Virtual PC and Xen, adopt substantially same solutions, that is, to provide a virtualized graphics card for a GOS. The virtualized graphics card is a general graphics card, which can only achieve basic displaying functions and is rather different from a real graphics card.
FIG. 1 is a schematic view showing the access to a graphics card in a prior art virtual machine system. The virtual machine system comprises a Virtual Machine Monitor (VMM), a Service Operating System (SOS), and at least one GOS (exemplified by one GOS in FIG. 1).
Upon starting, the SOS scans a PCI bus to find a real graphics card and acquire information on the real graphics card, so as to allocate resources (IRQs, IOs and MMIOs) for the real graphics card for the present system. The SOS accesses the graphics card by a drive module for the real graphics card.
The SOS comprises at least one Device Model (DM), each corresponding to one GOS and providing a virtual graphics card for the GOS. Upon starting, the GOS scans the PCI bus. The scanning operation of the GOS is intercepted by the VMM, and is forwarded to a virtual PCI bus in the DM. The DM registers a virtual graphics card for the GOS. The GOS finds the virtual graphics card, and acquires information on the virtual graphics card, so as to allocate resources (IRQs, IOs and MMIOs) for the virtual graphics card for the present GOS, which are stored in a PCI configuration space for the virtual graphics card of the DM, from which the VMM obtains the resource ranges for the virtual graphics card (interrupt numbers, respective IO segments and respective MMIO segments). When the GOS accesses the virtual graphics card by a drive module for the virtual graphics card, the accessing operation (IOs, MMIOs) of the GOS is intercepted by the VMM. The VMM sends the accessing data to the DM. The accessing data are converted by the DM, and then are sent to the drive module for the real graphics card. The drive module for the real graphics card processes the received data, and then sends them to the graphics card.
The virtual machine system comprises one or more GOSs, each accessing the graphics card by the SOS. Therefore, only the SOS may see the real graphics card and access the real graphics card by the drive module for the real graphics card, while each GOS sees the virtual graphics card provided by the DM and accesses the graphics card by the drive module for the virtual graphics card. Thus, the virtual machine system performs displaying by the SOS, without accelerating properties such as 2D and 3D. The hardware accelerating properties of the graphics card may not be used by the users and even the function of 3D animation is not supported, affecting the displaying performance. Further, when the respective GOSs perform displaying, data must be transferred and the environments must be switched among GOSs, the DM of the SOS, the drive module for the real graphics card of the SOS, and the VMM, resulting in a lowered system efficiency.
Moreover, when the GOS accesses the virtual graphics card by the drive module for the virtual graphics card, the drive module for the virtual graphics card sends the graphics card accessing data of the GOS to the DM by a communication module of the VMM; the DM converts the graphics card accessing data, and then sends them to the graphics card by the drive module for the real graphics card, thus achieving the access of the GOS to the graphics card.
From the above, the GOS directly accesses the virtual graphics card provided by the DM by means of the drive module for the virtual graphics card. Because the virtual graphics card is a general graphics card only achieving the basis displaying functions, the hardware accelerating properties of the real graphics card are not available for the users and the 2D or 3D animation functions are not supported, resulting in a poor displaying performance.